package com.example.fish.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.fish.entity.User;
import com.example.fish.mapper.UserMapper;
import com.example.fish.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public User createUser(User user) {
        this.save(user);
        return user;
    }

    @Override
    public User getByAccount(String account) {
        return lambdaQuery().eq(User::getAccount, account).one();
    }

    @Override
    public List<User> listAll() {
        return list();
    }

    @Override
    public boolean updateStatus(Integer idUser, String status) {
        return lambdaUpdate()
                .eq(User::getIdUser, idUser)
                .set(User::getStatus, status)
                .update();
    }
}
